package com.manli.api.util;

import com.manli.api.base.exception.MyException;
import com.manli.api.dao.SysWechatConfigDao;
import com.manli.api.dto.SysWechatConfig;
import com.manli.api.enums.ResultEnums;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class WeChatConfigUtil {
    @Autowired
    private SysWechatConfigDao sysWechatConfigDao;

    public SysWechatConfig getWeChatByAppid(String appid){
        SysWechatConfig bean = sysWechatConfigDao.createQuery().andEq("app_id",appid).andEq("active",1).singleSimple();
        if(bean == null){
            throw new MyException(ResultEnums.NO_ACTIVE_APPIDANDAPPSECRET);
        }
        return bean;
    }

}
